package jdk8;

/**
 * @author oldliu
 * @since 1.0
 */
public class Lambda1 {
    public static void main(String[] args) {
        //匿名内部类的方案
        m(new C(){
            @Override
            public int opp(int a, int b) {
                return a+b;
            }
        });
        System.out.println("---------------lambda方案---------------");
        m((a,b)->{
            return a*b;
        });
        System.out.println("--------------lambda方法2--------");
        //实现了C中唯一的方法opp
        C c=(i,j)->{
            return i-j;
        };
        int opp = c.opp(12, 15);
        System.out.println(opp);
        m(c);
    }
    static  void m(C c){
        int a=20, b=40;
        int r=c.opp(a,b);
        System.out.println("结果是："+r);
    }
}

interface C{
    int opp(int a,int b);

    default void test(){
        System.out.println("Test");
    }
}
